﻿//  --------------------------------
//  Copyright (c) PK Logix LLC. All rights reserved.
//  This source code is made available under the terms of the GNU General Public License version 2 (GPLv2)
//  http://www.codeplex.com/mvcclubsite/license
//  ---------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Reflection;
using MVCClubSite.IDAL;

namespace MVCClubSite.DALFactory
{
    /// <summary>
    /// This class is implemented following the Abstract Factory pattern.
    /// </summary>
    public sealed class DataAccess
    {
        private static readonly string assemblyName = ConfigurationManager.AppSettings["MVCClubSiteDAL"];

        private DataAccess() { }

        public static MVCClubSite.IDAL.IAnnouncements CreateAnnouncements()
        {
            string className = assemblyName + ".Announcements";
            return (IAnnouncements)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.IAlbums CreateAlbums()
        {
            string className = assemblyName + ".Albums";
            return (IAlbums)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.IImages CreateImages()
        {
            string className = assemblyName + ".Images";
            return (IImages)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.ILinks CreateLinks()
        {
            string className = assemblyName + ".Links";
            return (ILinks)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.ILocations CreateLocations()
        {
            string className = assemblyName + ".Locations";
            return (ILocations)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.IEvents CreateEvents()
        {
            string className = assemblyName + ".Events";
            return (IEvents)Assembly.Load(assemblyName).CreateInstance(className);
        }

        public static MVCClubSite.IDAL.IUserProfiles CreateUserProfiles()
        {
            string className = assemblyName + ".UserProfiles";
            return (IUserProfiles)Assembly.Load(assemblyName).CreateInstance(className);
        }
    }
}
